<?php
/**
 * Room View for RoomBooking Component
 * 
 * @version    1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license	   GNU/GPL
 */
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
 
jimport( 'joomla.application.component.view' );
 
class RoomBookingViewRoom extends JView
{
function display($tpl = null)
	{
		//get the room
		$item		=& $this->get('Data');
		$isNew		= ($item->id < 1);
		$modelBuildings = $this->getModel('buildings');
		$buildings =& $modelBuildings->getData();
                
                $modelTypes = $this->getModel('types');
		$types =& $modelTypes->getData();

		$text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
		JToolBarHelper::title(   JText::_( 'ROOM' ).': <small><small>[ ' . $text.' ]</small></small>' );
		JToolBarHelper::save();
		JToolBarHelper::apply();
		if ($isNew)  {
			JToolBarHelper::cancel();
		} else {
			// for existing items the button is renamed `close`
			JToolBarHelper::cancel( 'cancel', 'Close' );
		}
		
		$defaultOpt = new stdClass();
		$defaultOpt->id=null;
		$defaultOpt->name='- '.JText::_( 'SELBUILD' ).' -';
		array_push($buildings, $defaultOpt);
                
                $defaultOpt = new stdClass();
		$defaultOpt->id=null;
		$defaultOpt->name='- '.JText::_( 'SELTYPE' ).' -';
		array_push($types, $defaultOpt);
                
		$this->assignRef('item', $item);
		$this->assignRef('open', JHTML::_('select.booleanlist',  'open', 'class="inputbox"', $item->open ));
		$this->assignRef('building', JHTML::_('select.genericlist',$buildings, 'id_building', 'class="inputbox" style="width:300px"','id','name',$item->id_building));
                $this->assignRef('type', JHTML::_('select.genericlist',$types, 'room_type_id', 'class="inputbox" style="width:300px"','id','name',$item->room_type_id));
		
		parent::display($tpl);
	}
}
